#include <iostream>
#include <string>
using namespace std;

// 100.00 %
class Solution
{
  public:
	string countAndSay(int n)
	{
		string res = "1";
		while (--n)
		{
			res = convert(res);
		}
		return res;
	}
	string convert(string s)
	{
		string res = "";
		int count = 1;
		for (int i = 1; i < s.length(); i++)
		{
			if (s[i] != s[i - 1])
			{
				res += to_string(count) + s[i - 1];
				count = 1;
			}
			else
			{
				count++;
			}
		}
		res += to_string(count) + s[s.length() - 1];
		return res;
	}
};

int main()
{
	int n = 5;
	cout << Solution().countAndSay(n) << endl;
	return 0;
}
